package com.ruoyi;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 启动程序
 *
 * @author ruoyi
 */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@MapperScan({"com.ruoyi.*.mapper"})
@Slf4j
public class RuoYiApplication
{
    public static void main(String[] args)
    {
        // System.setProperty("spring.devtools.restart.enabled", "false");
	    ConfigurableApplicationContext run = SpringApplication.run(RuoYiApplication.class, args);
	    Environment env = run.getEnvironment();
	    String ip = null;
	    try {
		    ip = InetAddress.getLocalHost().getHostAddress();
	    } catch (UnknownHostException e) {
		    throw new RuntimeException(e);
	    }
	    String port = env.getProperty("server.port");
	    System.out.println( env.getProperty("server.servlet.context-path"));
	    String path = env.getProperty("server.servlet.context-path") == null ?  "" : env.getProperty("server.servlet.context-path");
		if(!path.endsWith("/")){
			path += "/";
		}

	    log.info("\n----------------------------------------------------------\n\t" +
			    "Application open-pub-Boot is running! Access URLs:\n\t" +
			    "Local: \t\thttp://localhost:" + port + path + "doc.html\n\t" +
			    "External: \thttp://" + ip + ":" + port + path + "doc.html\n\t" +
			    "doc.html: \thttp://localhost:" + port + path + "doc.html\n\t" +
			    "----------------------------------------------------------");
    }
}
